// 这是包的入口文件
const express = require('express')
const app = express()
const bodyParser = require('body-parser');
// 处理静态资源
app.use(express.static('public'));
// 处理参数
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: false }));

// 设置允许跨域返回问该服务
app.all('*', function(req, res, next) {
    res.header("Access-Control-Allow-Origin", "*");
    res.header("Access-Control-Allow-Origin", 'PUT,GET,POST,DELETE,OPTIONS');
    res.header("Access-Control-Allow-Origin", 'X-Requested-With');
    res.header("Access-Control-Allow-Origin", 'Content-Type');
    next();
});

app.get('/fdata', (req, res) => {
    res.send('hello world')
})
app.get('/axios', (req, res) => {
    res.send('axios get' + req.require.id);
})
app.post('/a1', (req, res) => {
    res.send('Post request')
})

app.listen(80, () => {
    console.log('http://127.0.0.1');
})